<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
    <title>用户注册页面</title>
    <base href="<%=basePath %>"/>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="favicon.ico" >
    <link rel="Shortcut Icon" href="favicon.ico" />
    <link rel="stylesheet" type="text/css" href="assets/H-ui/static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="assets/H-ui/static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="assets/H-ui/lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="assets/H-ui/static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="assets/H-ui/static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" href="assets/css/bootstrap.css"/>

    <link rel="stylesheet" type="text/css" href="assets/css/main.css">

</head>
<body>
<article class="cl pd-20">
    <form action="" method="post" class="form form-horizontal" id="form-admin-add">
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>帐号：</label>
            <div id="account11" class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="userAccount" name="userAccount" onblur="userAccountCheck(this.id, '帐号')">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>密码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="password" class="input-text" autocomplete="off" value="" placeholder="" id="password" name="userPwd1" onblur="nonEmpty(this.id,'密码')">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>确认密码：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <input type="password" class="input-text" autocomplete="off"  placeholder="" id="password2" name="userPwd" onblur="pwdCheck(this.id,'密码')">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>姓名：</label>
            <div id="userName11" class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="userName" name="userName" onblur="nameCheck(this.id, '姓名')">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><%--<span class="c-red">*</span>--%>性别：</label>
            <div class="formControls col-xs-8 col-sm-9 skin-minimal">
                <div class="radio-box">
                    <input name="userSex" type="radio" id="userSex_1" value="1" checked>
                    <label for="userSex_1">男</label>
                </div>
                <div class="radio-box">
                    <input name="userSex" type="radio" id="userSex_2" value="2">
                    <label for="userSex_2">女</label>
                </div>
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>年龄：</label>
            <div id="userAge11" class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="userAge" name="userAge" onblur="ageCheck(this.id,'年龄')">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>手机：</label>
            <div id="mobile11" class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="mobile" name="mobile" onblur="modeleCheck(this.id,'手机号')">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>卡号：</label>
            <div id="cardNumber11" class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="cardNumber" name="cardNumber" onblur="cardNumberCheck(this.id,'卡号')">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>身份证：</label>
            <div id="identityId11" class="formControls col-xs-8 col-sm-9">
                <input type="text" class="input-text" value="" placeholder="" id="identityId" name="identityId" onblur="identityIdCheck(this.id,'身份证')">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-3">住址：</label>
            <div class="formControls col-xs-8 col-sm-9">
                <textarea name="userSite" id="userSite" cols="" rows="" class="textarea"  placeholder="填写住址信息" dragonfly="true" onKeyUp="textarealength(this,100)"></textarea>
                <p class="textarea-numberbar"><em class="textarea-length">0</em>/100</p>
            </div>
        </div>
        <div class="row cl">
            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <input class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" onclick="submission()">
            </div>
        </div>
    </form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="assets/H-ui/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="assets/H-ui/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="assets/H-ui/static/h-ui/js/H-ui.js"></script>
<script type="text/javascript" src="assets/H-ui/static/h-ui.admin/js/H-ui.admin.page.js"></script>

<!--/_footer /作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="assets/H-ui/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="assets/H-ui/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="assets/H-ui/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="assets/js/addUser.js"></script>
<script type="text/javascript">
    function submission() {
        if ($("#userName").val() == "") {
            alert("带*号的为必填，请重新填写！！")
            return;
        };
        if($("#userAccount").val() == ""){
            alert("带*号的为必填，请重新填写！！")
            return;
        };
        if($("#password2").val() == ""){
            alert("带*号的为必填，请重新填写！！")
            return;
        };
        if ($("#userAge").val() == "") {
            alert("带*号的为必填，请重新填写！！")
            return;
        };
        if ($("#mobile").val() == "") {
            alert("带*号的为必填，请重新填写！！")
            return;
        };
        if ($("#cardNumber").val() == "") {
            alert("带*号的为必填，请重新填写！！")
            return;
        };
        if ($("#identityId").val() == "") {
            alert("带*号的为必填，请重新填写！！")
            return;
        };

        var password = $("#password").val();
        var userPwd = $("#password2").val();
        if (password != userPwd) {
            alert("密码不一致，请从新输入！！")
            return;
        };

        var userAccount = $("#userAccount").val();
        var userName = $("#userName").val();
        var userSex = $("input[name='userSex']:checked").val();
        var userAge = $("#userAge").val();
        var mobile = $("#mobile").val();
        var cardNumber = $("#cardNumber").val();
        var identityId = $("#identityId").val();
        var userSite = $("#userSite").val();

        $.ajax({
            url : "frontUser/cardNumberCheck.action",
            data : {
                "cardNumber" : cardNumber
            },
            type : "post",
            dataType : "text",
            success : function (result) {
                if (result=="error") {
                    // layer.tips('该卡可以使用！', '#cardNumber11', {tips: [2, '#00ff00']});

                    $.ajax({
                        url : "frontUser/registerUser.action",
                        data : {
                            "userName" : userName,
                            "userAccount" : userAccount,
                            "userPwd" : userPwd,
                            "userSex" : userSex,
                            "userAge" : userAge,
                            "mobile" : mobile,
                            "cardNumber" : cardNumber,
                            "identityId" : identityId,
                            "userSite" : userSite
                        },
                        type : "post",
                        dataType : "text",
                        success : function (res) {
                            if(res == "success" ){
                                window.alert("注册成功！！");
                                window.location.href="operationUser/showUser.action";
                            }else if(res == "error"){
                                window.alert("注册失败！！")
                                // window.location.href="manageUser/showRegisterUser.action";
                            }
                        }
                    });
                } else if (result=="success") {
                    layer.tips('该卡已被使用！', '#cardNumber11', {tips: [2, '#CC3333']});
                    return;
                }
            }
        });


    }

</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>